package com.bytecodezz.app.framework.base.general

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

/**
 * @author: bytecodezz
 * @version: 1.0
 * @time: 2021/7/5 16:52
 * @package: com.bytecodezz.app.framework.base
 *
 * @description: Fragment基类，不建议直接基础，如果直接继承，里面过多的抽象方法需要实现
 *  主要提供的功能
 *  1、提供2中方式设置布局，按先后顺序：generateContentView返回Int、generateContentView返回View
 *  2、
 *  3、
 */
abstract class BaseFragment : Fragment(), IBaseFragment {
    private lateinit var _rootView: View
    val rootView: View get() = _rootView
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _rootView = generateContentView()?.let {
            inflater.inflate(it, container, false)
        } ?: generateContentView(inflater, container, savedInstanceState)!!
        onActionStart(rootView)
        return _rootView
    }
}